

//
//  AppTools.m
//  UI-豆瓣项目APP
//
//  Created by dllo on 15/9/8.
//  Copyright (c) 2015年 孙鹏. All rights reserved.
//

#import "AppTools.h"
#import "AFNetworking.h"
@interface AppTools ()



@end

@implementation AppTools

+(void)getDataWithUrlStr:(NSString *)urlStr andBlock:(AppToolsBlock) appBlock error:(ErrorBlock)myerror{
    
    NSError *error2 = nil;
    NSString *urlEncode = [urlStr stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
    
    AFHTTPRequestOperationManager* manager = [AFHTTPRequestOperationManager manager];
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"text/plain",@"text/json",@"application/json",@"text/javascript",@"text/html",nil];
    [manager GET:urlEncode parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
        
        //block回调
        appBlock(responseObject);
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        
        NSLog(@"失败==== %@",error);
        
        myerror(error2);
    }];
}




@end
